<template>
	<!-- 工商银行 -->
	<view>
		<view class="tit">
			<image class="titBg" src="../../static/bank-icon11.png" mode="widthFix"></image>
			<view class="kanum">尾号{{list.balance.bankCode.substr(15,4)}}</view>
			<view class="numtxt">人民币余额:{{list.balance.showBalance}}</view>
			<view class="backBtn" @tap="backBtn"></view>
		</view>
		<view class="moneyNum">
			<view>当前人民币汇总</view>
			<view style="color: #f29699;">收+{{list.inAmount}}</view>
			<view style="color: #5ac994;">支-{{list.outAmount}}</view>
		</view>
		<view class="myDateTime">{{year}}年{{month}}月</view>
		<view class="detailedMain">
			<view v-for="(item,index) in list.list" :key="index">
				<view class="month">
					<view>{{item.showDate.substr(8,2)}}</view>
					<view>{{item.week}}</view>
				</view>
				<view>
					<view class="detailedList" v-for="(item1,index) in item.list" :key="index" @tap="delBtn" :data-id="item1.id">
						<view>
							<view>{{item1.payTypeStr}}</view>
							<view style="font-size: 4vw;" :class="item1.payType==0?'mygreen':'myred'">{{item1.payType==0?'+':'-'}}{{item1.showAmount}}</view>
						</view>
						<view>
							<view>{{item1.name}}</view>
							<view>余额:{{item1.amount2}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const http = require('../../utils/http.js');
	export default {
		data() {
			return {
				id:null,
				list:null,
				year:null,
				month:null
			}
		},
		onLoad(options) {
			this.id=options.id
		},
		onShow() {
			var now = new Date();
			this.year = now.getFullYear(); //年
			if((now.getMonth() + 1) < 10){ //月
				this.month = '0'+(now.getMonth() + 1)
			}else{
				this.month = now.getMonth() + 1;
			}
			uni.showLoading({
			    title: '加载中'
			});
			http.get('/api/balance/getBalanceDetail',{balanceId:this.id}).then(res => {
				//console.log(res.result.balance.bankCode)
				//console.log(res.result.balance.bankCode.replace(/^(\w{4})\w{10}(.*)$/, '$1***$2'))
				if (res.code == 200 && res.result) {
					this.list=res.result
				}
				uni.hideLoading();
			})
			
		},
		methods: {
			backBtn:function(){
				uni.navigateBack({
					delta: 1
				})
			},
			delBtn:function(e){
				var that=this
				uni.showModal({
				    title: '删除',
				    content: '确定删除该数据吗？',
				    success: function (res) {
				        if (res.confirm) {
				            //console.log(e.currentTarget.dataset.id);
							uni.showLoading({
							    title: '加载中'
							});
							http.get('/api/balance/delBalanceDetail',{balanceDetailId:e.currentTarget.dataset.id}).then(res => {
								uni.showToast({
								  title: res.message,
								  icon: 'none'
								});
								if(res.code==200){
									http.get('/api/balance/getBalanceDetail',{balanceId:that.id}).then(res1 => {
										if (res1.code == 200 && res1.result) {
											that.list=res1.result
										}
									})
								}
								uni.hideLoading();
							})
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			}
		}
	}
</script>

<style>
	page{
		color: #333333;
		font-family: 'jtfont-icon';
	}
	@font-face {
		font-family:jtfont-icon;
		src: url('~@/fonts/gsfont.otf');
	}
	.myred{
		color: #f29699;
	}
	.mygreen{
		color: #00c192;
	}
	.backBtn{
		width: 10vw;
		height: 10vw;
		position: absolute;
		top: 9.5vw;
		left: 4vw;
	}
	.tit{
		position: relative;
	}
	.titBg{
		width: 100%;
	}
	.kanum{
		position: absolute;
		top: 25.2vw;
		left: 45vw;
		color: #666666;
		font-size: 3.5vw;
	}
	.numtxt{
		position: absolute;
		top: 31vw;
		left: 22.4vw;
		color: #666666;
		font-size: 3.2vw;
	}
	.moneyNum{
		display: flex;
		flex-direction: row;
		align-items: center;
		font-size: 3.6vw;
		padding: 1vw 4.2vw;
		border-top: 2px solid #F2F2F2;
	}
	.moneyNum>view{
		margin-right: 5.4vw;
	}
	.myDateTime{
		padding: 1.4vw 4.2vw;
		background: #eeeeee;
		font-size: 5vw;
	}
	.detailedMain{
		
	}
	.detailedMain>view{
		display: flex;
		flex-direction: row;
		border-bottom: 1px solid #F2F2F2;
	}
	.detailedMain .month{
		display: flex;
		flex-direction: column;
		align-items: center;
		padding: 1vw 4.2vw;
		color: #8d9aa0;
	}
	.detailedMain>view>view:nth-child(2){
		flex: 1;
	}
	.detailedMain .month>view:nth-child(1){
		font-size: 5.2vw;
		margin-bottom: 0.6vw;
	}
	.detailedMain .month>view:nth-child(2){
		font-size: 3.1vw;
	}
	.detailedList{
		background: #FFFFFF;
		padding: 1vw 3.6vw 3.1vw 0;
		border-bottom: 1px solid #F2F2F2;
	}
	.detailedList:last-child{
		border-bottom: none;
	}
	.detailedList>view:nth-child(1){
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		font-size: 3.8vw;
		color: #333333;
		margin-bottom: 1.4vw;
	}
	.detailedList>view:nth-child(2){
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		font-size: 3.4vw;
		color: #666666;
	}
	.detailedList>view:nth-child(2)>view:nth-child(2){
		color: #333333;
	}
</style>
